//
//  FeedbackBoardViewController.m
//  TestARC
//
//  Created by 吴 晓泉 on 13-2-24.
//
//

#import "FeedbackBoardViewController.h"
#import "FeedbackViewController.h"

@interface FeedbackBoardViewController ()

@end

@implementation FeedbackBoardViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)rateMyApp:(id)sender
{
    NSLog(@"打开评分");
    
//    //1.跳转方式评分
//    NSString *str = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=597131526";
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    
    //2.应用内评分
    [self evaluate];
    
    //内部打开web方式
    //    DrugWebViewController *webController = [[DrugWebViewController alloc]initWithNibName:@"DrugWebViewController" bundle:nil];
    //    webController.url = str;
    //    webController.title = @"app stroe";
    //    [self.navigationController pushViewController:webController animated:YES];
}

- (IBAction)feedback:(id)sender
{
    FeedbackViewController *detailViewController = [[FeedbackViewController alloc]initWithNibName:@"FeedbackViewController" bundle:nil];
    detailViewController.title = @"请输入反馈建议";
    [self.navigationController pushViewController:detailViewController animated:YES];
}
- (void)evaluate{
    [self showWaitView:@"请稍等..."];
    //初始化控制器
    SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
    //设置代理请求为当前控制器本身
    storeProductViewContorller.delegate = self;
    //加载一个新的视图展示
    [storeProductViewContorller loadProductWithParameters:
     //appId唯一的
     @{SKStoreProductParameterITunesItemIdentifier : @"597131526"} completionBlock:^(BOOL result, NSError *error) {
         //block回调
         [self hideWaitView];
         if(error){
             NSLog(@"error %@ with userInfo %@",error,[error userInfo]);
         }else{
             //模态弹出appstore
             [self presentViewController:storeProductViewContorller animated:YES completion:^{
                 
             }
              ];
         }
     }];
}
//取消按钮监听
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

@end
